Skip to content

feat(engine): image input in the ATOMesh standalone service - #3413

Closed
junyyang-amd wants to merge 8 commits into
junyyang/mm-epd-e3from
junyyang/mm-epd-e4
Closed

junyyang-amd wants to merge 8 commits into
junyyang/mm-epd-e3from
junyyang/mm-epd-e4

Conversation

@junyyang-amd

@junyyang-amd junyyang-amd commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review. PR 5 of 9 in stack #3730: #3410 → #3407 → #3411 → #3412 → this PR → #3408 → #3409 → #3415 → #3417. Stacked on #3412; this PR's diff is its own change only.

Why

ATOMesh is gaining image chat for MiniMax-M3.1 and Kimi-K3.1 as a single instance, 1P1D and E/P/D; this series replaces #3371, and #3417 is its design. Before this PR, the ATOMesh standalone service rendered only a message's text parts. A red photo sent with "What color is this?" reached the model as the question alone, and the model answered without seeing it.

What changed

flowchart LR
  A[chat request] --> B{image parts?}
  B -- no --> C[chat template, text prompt]
  B -- yes --> D["check_chat_images, then the native server's preparation (new)"]
  D -- malformed --> X[ValueError, a 400 at the router]
  D --> E["token ids plus multimodal_data (new)"]
  C --> F[engine, blocking or streaming]
  E --> F
Loading
  • A chat with images, blocking or streaming, reaches the engine as token ids with expanded image placeholders and multimodal_data (_chat_engine_input).
  • The native server's preparation is split into load_multimodal_processor and prepare_chat_multimodal_inputs, which both servers call.
  • The service loads the processor once, under a lock, on its first image request.
  • A server path, file URL, bad base64, non-image, assistant image or video part raises ValueError before anything reaches the engine.
  • A token-id prompt counts its ids as prompt tokens and reads its reasoning channel from the tokens.

Review focus

  • The service's chat path still forwards no kv_transfer_params, as for text, so image chat here serves a single instance.

Testing

An image_url or file image reaches the engine with placeholders expanded and pixels intact. The processor loads once. Each malformed part is a ValueError with nothing sent to the engine; text-only chat renders as text.
Kimi-K3.1 and MiniMax-M3.1 name red and blue images.
CPU unit suite green except test_mxfp4_apply_hands_the_shared_output_to_fused_experts, which fails the same way on main (from #2713).

Follow-ups

  • Through ATOMesh, a file part is a 400: openai-protocol 1.0.0 lacks it.
Evidence

In tests/entrypoints/test_atom_standalone_service_images.py, blocking and streaming each:

  • test_an_image_reaches_the_engine_with_its_placeholders[image_url|file]: prompt [9] + [42] * 4 + [8], spans ((1, 4),), first pixel [255, 0, 0], usage equal to the prompt length.
  • test_the_processor_is_loaded_once.
  • test_a_malformed_image_part_is_the_clients_error[server-path|file-url|bad-base64|not-an-image|assistant|video].
  • test_a_text_only_request_is_rendered_as_text.

Real processor, standalone service (USE_ATOMESH_ENTRYPOINTS=1), "What color is this image? Answer with one word.", temperature 0:

model part blocking red / blue streaming red / blue prompt tokens
Kimi-K3.1 TP8 image_url Red / Blue Red / Blue 363
MiniMax-M3.1 TP4 image_url Red / Blue Red / Blue 444
both file 400 / 400 400 / 400 none

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes needed..

any real-processor run for kimi-k3.1 / minimax-m3.1 image chat through the standalone service?

ci green.

placeholders, so its prompt arrives as token ids. Blocking.
"""
messages = self._get_chat_messages(request_data)
if has_multimodal_content(messages):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gate runs before check_chat_images, so a file image part falls to the text path and gets dropped. run check_chat_images first and gate on the checked messages, like api_server does.

junyyang-amd added a commit that referenced this pull request Nov 23, 2026
Addresses the review of #3417:
- Each decision names the PR of the stack that implements it (#3410,
  #3407, #3411-#3413, #3408, #3409, #3414-#3416); the Acceptance table
  names the PR that adds each check.
- No reference outside ROCm/ATOM remains: the requirement, the
  measurements and the rules decisions rest on are stated in place.
- D4/D5 follow #3410: decode clears `is_multimodal` when P kept the
  media; only the non-streaming single branch returns `cache_seed`.
- D6 names the scheduler's actual refusal of a media-less local prefill.
- D3 and A3 describe the route-log `match_ratio` check.
- D11 says why matched rails do not apply; D12 states E's word handling
  as implemented, the 503 on a full pool, and the open gap: P's TP ranks
  do not agree on a read of E's embeddings. D13 notes
  `image_grid_thw` is dropped with the pixels once leased.
- Harness facts follow #3416's defaults (g07, g08, g24 and HCA maps).
- The CLAUDE.md row marks the guide as the design of its PR stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@junyyang-amd
junyyang-amd removed this pull request from stack #3699 November 23, 2026 07:14
@junyyang-amd
junyyang-amd added this pull request to stack #3730 November 23, 2026 07:15
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@valar-cop valar-cop left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some changes needed..

ci green.

placeholders, so its prompt arrives as token ids. Blocking.
"""
messages = self._get_chat_messages(request_data)
if has_multimodal_content(messages):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still open: gate runs before check_chat_images, so a file part image is silently dropped. run check_chat_images first and gate on the checked messages, like api_server does.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2a97bfb: check_chat_images runs first and the gate reads the checked messages. test_an_image_reaches_the_engine_with_its_placeholders[file] fails without it.

junyyang-amd and others added 2 commits November 23, 2026 14:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `file` image part is an image only once check_chat_images has put it in
its `image_url` form; gated first, it fell to the text path and was dropped.
Check first and gate on the checked messages, as the OpenAI server does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@junyyang-amd

Copy link
Copy Markdown
Contributor Author

Round 2 pushed 2a97bfb: the inline fix. The stack above is restacked on it.

Real-processor runs, standalone service on MI355X, red and blue images, blocking and streaming:

  • Kimi-K3.1 at TP8: 4/4 image_url requests name their color, 363 prompt tokens each.
  • MiniMax-M3.1 at TP4: 4/4 image_url requests name their color, 444 prompt tokens each.
  • Both: a file part is a 400 in ATOMesh's parser, before the service: openai-protocol 1.0.0 has no file part.
Evidence

Prompt "What color is this image? Answer with one word.", temperature 0, a 448x448 solid PNG as a base64 data URL.

model part blocking red / blue streaming red / blue
Kimi-K3.1 image_url Red / Blue Red / Blue
MiniMax-M3.1 image_url Red / Blue Red / Blue
both file 400 / 400 400 / 400

The 400 body: {"error":{"type":"invalid_request_error","code":"invalid_request","message":"data did not match any variant of untagged enum MessageContent ..."}}.

branch @ 2a97bfb: 490 passed across the standalone service's test files. black, ruff clean.

@junyyang-amd
junyyang-amd requested a review from jgong5 November 23, 2026 14:42
junyyang-amd added a commit that referenced this pull request Nov 24, 2026
#3698 replaced the Python standalone service, which #3413 extended, with a
Rust frontend that refuses images. The CI case was never served through it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@junyyang-amd
junyyang-amd removed this pull request from stack #3730 November 24, 2026 05:24
@junyyang-amd

Copy link
Copy Markdown
Contributor Author

No blocking issues. Closed as superseded by #3698, which replaced the Python standalone service this PR extends. Its Rust frontend refuses an image request with a 400 (multimodal_unsupported).

Image chat through ATOMesh goes through ATOM's OpenAI server, as #3410, #3407, #3408 and #3409 serve it. Stack #3730 continues without this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants